import Layout from 'src/pages/layout/layout'

// 不作为main组件子页面展示的页面单独写，如下
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: 'Login - 登录'
  },
  component: () => import('src/pages/login/login')
}

// 错误页面
export const errorRouter = {
  path: '/error/:code',
  name: 'error',
  meta: {
    title: 'error'
  },
  component: () =>
    import('src/pages/error/index')
}

// 作为main组件子页面展示  但不在左侧菜单显示的路由卸载otherRoter里
export const otherRouter = {
  path: '',
  name: 'otherRouter',
  redirect: '/home',
  meta: {
    requireAuth: true
  },
  component: Layout,
  children: [
    {
      path: 'home',
      name: 'home',
      title: '首页',
      component: () => import('src/pages/home/home')
    }
  ]
}

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
  {
    path: '/business',
    name: 'business',
    title: '商家管理',
    meta: {
      requireAuth: true,
      permissions: ['U_1']
    },
    component: Layout,
    children: [
      {
        path: 'businessList',
        name: 'businessList',
        title: '商家列表',
        meta: {
          permissions: ['U_1_1']
        },
        component: () => import('src/pages/business/businessList')
      },
      {
        path: 'businessCheck',
        name: 'businessCheck',
        title: '商家审核',
        meta: {
          permissions: ['U_1_1']
        },
        component: () => import('src/pages/business/businessCheck')
      },
      {
        path: 'businessLook',
        name: 'businessLook',
        title: '查看商家',
        component: () => import('src/pages/business/businessLook')
      },
      {
        path: 'businessEdit',
        name: 'businessEdit',
        title: '编辑商家',
        component: () => import('src/pages/business/businessEdit')
      }
    ]
  },
  {
    path: '/account',
    name: 'account',
    title: '角色与权限管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'roleList',
        name: 'roleList',
        title: '角色列表',
        component: () => import('src/pages/account/roleList')
      },
      {
        path: 'userList',
        name: 'userList',
        title: '管理员列表',
        component: () => import('src/pages/account/userList')
      }
    ]
  },
  {
    path: '/order',
    name: 'order',
    title: '订单管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'platformOrder',
        name: 'platformOrder',
        title: '平台订单管理',
        component: () => import('src/pages/order/platformOrder')
      },
      {
        path: 'businessOrder',
        name: 'businessOrder',
        title: '商家订单管理',
        component: () => import('src/pages/order/businessOrder')
      }
    ]
  },
  {
    path: '/activity',
    name: 'activity',
    title: '活动管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'activity',
        name: 'activity',
        title: '活动管理',
        component: () => import('src/pages/activity/activity')
      }
    ]
  },
  {
    path: '/goods',
    name: 'goods',
    title: '商品管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'goodsList',
        name: 'goodsList',
        title: '商品列表',
        component: () => import('src/pages/goods/goodsList')
      }
    ]
  },
  {
    path: '/agent',
    name: 'agent',
    title: '代理商管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'agent',
        name: 'agent',
        title: '代理商管理',
        component: () => import('src/pages/agent/agent')
      }
    ]
  },
  {
    path: '/money',
    name: 'money',
    title: '财务管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'moneyShop',
        name: 'moneyShop',
        title: '商家财务管理',
        component: () => import('src/pages/money/moneyShop')
      }, {
        path: 'moneyPlat',
        name: 'moneyPlat',
        title: '平台财务管理',
        component: () => import('src/pages/money/moneyPlat')
      }, {
        path: 'moneyAgent',
        name: 'moneyAgent',
        title: '代理商财务管理',
        component: () => import('src/pages/money/moneyAgent')
      }
    ]
  },
  {
    path: '/data',
    name: 'data',
    title: '数据统计',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'orderData',
        name: 'orderData',
        title: '交易量统计',
        component: () => import('src/pages/data/orderData')
      }, {
        path: 'goodsData',
        name: 'goodsData',
        title: '商品数量统计',
        component: () => import('src/pages/data/goodsData')
      }, {
        path: 'userData',
        name: 'userData',
        title: '会员数量统计',
        component: () => import('src/pages/data/userData')
      }, {
        path: 'agentData',
        name: 'agentData',
        title: '代理商数量统计',
        component: () => import('src/pages/data/agentData')
      }, {
        path: 'shopData',
        name: 'shopData',
        title: '商家数量统计',
        component: () => import('src/pages/data/shopData')
      }, {
        path: 'pensionData',
        name: 'pensionData',
        title: '养老金统计',
        component: () => import('src/pages/data/pensionData')
      }
    ]
  },
  {
    path: '/user',
    name: 'user',
    title: '会员管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'userList',
        name: 'userList',
        title: '用户管理',
        component: () => import('src/pages/user/userList')
      }
    ]
  },
  {
    path: '/pension',
    name: 'pension',
    title: '养老金管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'pensionDetail',
        name: 'pensionDetail',
        title: '养老金明细',
        component: () => import('src/pages/pension/pensionDetail')
      }, {
        path: 'pensionApply',
        name: 'pensionApply',
        title: '养老金申请',
        component: () => import('src/pages/pension/pensionApply')
      }, {
        path: 'pensionGot',
        name: 'pensionGot',
        title: '养老金领取记录',
        component: () => import('src/pages/pension/pensionGot')
      }
    ]
  },
  {
    path: '/configure',
    name: 'configure',
    title: '配置',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'bannerConfig',
        name: 'bannerConfig',
        title: 'banner配置',
        component: () => import('src/pages/configure/bannerConfig')
      },
      {
        path: 'btnConfig',
        name: 'btnConfig',
        title: '商品分类',
        component: () => import('src/pages/configure/btnConfig')
      }
    ]
  },
  {
    path: '/log',
    name: 'log',
    title: '操作日志',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'log',
        name: 'log',
        title: '操作日志',
        component: () => import('src/pages/log/log')
      }
    ]
  }, {
    path: '/opinion',
    name: 'opinion',
    title: '反馈意见管理',
    meta: {
      requireAuth: true
    },
    component: Layout,
    children: [
      {
        path: 'opinion',
        name: 'opinion',
        title: '反馈意见管理',
        component: () => import('src/pages/opinion/opinion')
      }
    ]
  }
]

export const routers = [
  loginRouter,
  errorRouter,
  otherRouter,
  ...appRouter
]
